package system

import (
	"game-simple/internal/framework/system/controllers"

	"github.com/gin-gonic/gin"
)

// Module 系统模块
type Module struct {
	sequenceController *controllers.SequenceController
}

// NewModule 创建系统模块实例
func NewModule() *Module {
	return &Module{
		sequenceController: controllers.NewSequenceController(),
	}
}

// RegisterRoutes 注册系统相关路由
func (m *Module) RegisterRoutes(r *gin.RouterGroup) {
	// 健康检查
	r.GET("/health", func(ctx *gin.Context) {
		ctx.JSON(200, gin.H{"status": "ok"})
	})

	// 编号规则路由
	systemGroup := r.Group("/api/system")
	{
		systemGroup.GET("/sequence-rules", m.sequenceController.ListRules)
		systemGroup.POST("/sequence-rules", m.sequenceController.CreateRule)
		systemGroup.GET("/sequence-rules/:code", m.sequenceController.GetRule)
		systemGroup.PUT("/sequence-rules/:code", m.sequenceController.UpdateRule)
		systemGroup.DELETE("/sequence-rules/:code", m.sequenceController.DeleteRule)
		systemGroup.POST("/sequence-rules/generate", m.sequenceController.GenerateSequence)
	}
}
